//
//  UIimageTableViewCell.m
//  XMenSwift
//
//  Created by Jason on 2022/3/22.
//

#import "UIimageTableViewCell.h"
#import <Masonry/Masonry.h>
#import "Utils.h"


@interface UIimageTableViewCell()
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *contenLabel;
@property (strong, nonatomic) UILabel *bootomLabel;
@property (strong, nonatomic) UIImageView *photoImageView;

@end

@implementation UIimageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self steupUi];
    }
    return self;
}

- (void)steupUi {
    
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgView];
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor grayColor];
    line.alpha = 0.4;
    [self.contentView addSubview:line];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.image = [UIImage imageNamed:@"bigXiong"];
    imageView.clipsToBounds = YES;
    self.photoImageView = imageView;
    ViewRadius(imageView, 5.0);
    [bgView addSubview:imageView];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:16.0];
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.text = @"这是标题最大一行试试这是标题最大一行试试这是标题最大一行试试这是标题最大一行试试";
    titleLabel.numberOfLines = 1;
    [bgView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *contenLabel = [[UILabel alloc] init];
    contenLabel.font = [UIFont systemFontOfSize:14.0];
    contenLabel.textColor = [UIColor redColor];
    contenLabel.text = @"这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气";
    contenLabel.numberOfLines = 2;
    [bgView addSubview:contenLabel];
    self.contenLabel = contenLabel;
    
    UILabel *bootomLabel = [[UILabel alloc] init];
    bootomLabel.font = [UIFont systemFontOfSize:14.0];
    bootomLabel.textColor = [UIColor redColor];
    bootomLabel.text = @"这是底部标题";
    bootomLabel.numberOfLines = 1;
    [bgView addSubview:bootomLabel];
    self.bootomLabel = bootomLabel;
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
        make.bottom.mas_equalTo(0);
    }];
    
    [self.photoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView);
        make.left.equalTo(bgView);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(100);
        make.bottom.equalTo(bgView.mas_bottom);

    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView);
        make.left.equalTo(self.photoImageView.mas_right).offset(10);
        make.right.equalTo(bgView);
        make.height.mas_greaterThanOrEqualTo(18);
    }];
    
    [self.contenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(titleLabel.mas_bottom).offset(10);
        make.left.equalTo(titleLabel);
        make.right.equalTo(titleLabel).offset(-15);
        make.centerY.equalTo(self.photoImageView);
    }];
    
    [self.bootomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(contenLabel.mas_bottom).offset(10);
        make.height.mas_greaterThanOrEqualTo(18);
        make.left.equalTo(titleLabel);
        make.right.equalTo(titleLabel).offset(-15);
        make.bottom.equalTo(self.photoImageView.mas_bottom).offset(0);

    }];
    
}

@end
